package service;

import java.util.List;

import beans.Agent;
import beans.Package;

import dao.QueryDAO;


public class ParcelService implements ParcelServiceInterface {

    private List<Package> parcels = null;

    QueryDAO queryDAO = new QueryDAO();

    String sql = null;
    String hql = null;

    public List<Package> getParcels(Agent agent,int rows,int page) {
        hql = "from Package p where p.terminal.branch.agent.id = ?";
        return queryDAO.queryByPage(hql, page, rows, agent.getId());
    }

    public int getParcelNumber(Agent agent) {
        hql = "select count(p.packageId) from Package p where p.terminal.branch.agent.id = ?";
        return ((Long)queryDAO.queryUnique(hql, agent.getId())).intValue();
    }

}